package main

import (
	"google.golang.org/grpc"
	"log"
	"study/go-php-grpc/pb"
	"golang.org/x/net/context"
	"time"
	"fmt"
)

const (
	address     = ":8888"
)

func main() {
	conn, err := grpc.Dial(address, grpc.WithInsecure())
	if err != nil {
		log.Fatalln("conn err", err.Error())
	}
	defer conn.Close()
	c := hello_pb.NewHelloClient(conn)
	ctx, cancel := context.WithTimeout(context.Background(), time.Second * 5)
	defer cancel()
	req := &hello_pb.SayHelloRequest{
		Content:"go-php",
	}
	result, err := c.SayHello(ctx, req)
	if err != nil {
		log.Fatalln("client err", err.Error())
	}
	//输出结果
	fmt.Println(result.Result)
}
